/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.open.api.core.service.processor.base.pre;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.common.core.util.IdUtil;
import info.peigen.hotpot.component.open.api.core.service.processor.base.AbstractOpenApiServiceProcessor;
import info.peigen.hotpot.component.open.api.facade.Api;
import info.peigen.hotpot.component.open.api.facade.order.OpenApiOrder;
import info.peigen.hotpot.component.open.api.facade.processor.base.OpenApiProcessor;
import info.peigen.hotpot.component.open.api.facade.processor.base.OpenApiProcessorServiceContext;
import org.noear.solon.annotation.Component;


/**
 * <b>(OpenApiDecryptProcessor)</b>
 * 解密
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/6/13
 */
@SuppressWarnings("rawtypes")
@Component
public class OpenSimpleApiProcessor extends AbstractOpenApiServiceProcessor implements OpenApiProcessor {
    @Override
    public Integer level() {
        return 5;
    }

    @Override
    public void execute(OpenApiProcessorServiceContext serviceContext) {
        OpenApiOrder order = serviceContext.getOrder();
        Api          api   = BeanUtil.copyProperties(order, Api.class).setGid(IdUtil.gid());
        api.setDecrypt(api.getEncrypt());
        serviceContext.setApi(api);
    }
}